package com.usian.article.controller;

import com.usian.apis.article.ApArticleControllerApi;
import com.usian.article.service.impl.ApArticleServiceImpl;
import com.usian.model.article.pojos.ApArticle;
import com.usian.model.article.pojos.ApArticleConfig;
import com.usian.model.article.pojos.ApArticleContent;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xiaowanmate
 * @date 2023/2/24 10:43
 */
@RestController
@RequestMapping("/api/v1/article")
public class ApArticleController implements ApArticleControllerApi {

    @Autowired
    private ApArticleServiceImpl apArticleService;


    @Override
    @PostMapping("/saveArticle")
    public ApArticle saveArticle(@RequestBody ApArticle article) {
        return apArticleService.saveArticle(article);
    }

    @Override
    @PostMapping("/saveArticleConfig")
    public ResponseResult saveArticleConfig(@RequestBody ApArticleConfig config) {
        apArticleService.saveArticleConfig(config);
        return apArticleService.success;
    }

    @Override
    @PostMapping("/saveArticleContent")
    public ResponseResult saveArticleContent(@RequestBody ApArticleContent content) {
        apArticleService.saveArticleContent(content);
        return apArticleService.success;
    }
}
